#!/bin/bash

# 编译脚本
echo "=== Building File Server ==="

# 默认构建类型
BUILD_TYPE=${1:-Release}

echo "Build type: $BUILD_TYPE"

# 创建build目录
mkdir -p build
cd build

# 运行CMake
echo "Running CMake..."
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE

# 编译
echo "Compiling..."
make -j$(nproc)

# 检查编译结果
if [ $? -eq 0 ]; then
    echo "✓ Build successful!"
    echo "Executable: out/bin/$BUILD_TYPE/file_server"
    echo "Libraries:  out/lib/$BUILD_TYPE/"
    ls -lh ../out/bin/$BUILD_TYPE/
    ls -lh ../out/lib/$BUILD_TYPE/
else
    echo "✗ Build failed!"
    exit 1
fi
